The AdRotator is a special control in ASP.NET that is used to display flashing banner ads The control is capable of displaying ads randomly or sequentially as set by the user.
Each time the page is refreshed or reloaded a new ad can be displayed to the user. Also, we can assign priorities in such a way that certain ads are displayed frequently than others.
<asp:AdRotator ID="AdRotator2" runat="server" />
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>image_5.png</ImageUrl>
<NavigateUrl>home.aspx</NavigateUrl>
<Impressions>1</Impressions>
</Ad>
<Ad>
<ImageUrl>asp_net-design-logo.jpg</ImageUrl>
<NavigateUrl>home.aspx</NavigateUrl>
<Impressions>2</Impressions>
</Ad>
</Advertisements>
<Impressions>: (Optional) The display rates in percent of the hits. The larger the number, the more often the ad is displayed.
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" OnAdCreated="AdRotator1_AdCreated" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile2.xml">
</asp:XmlDataSource>
The AdCreated event is raised on the server after the AdRotator control is created, but before the page is rendered.
If the AdvertisementFile property is set, the AdCreated event is raised after an advertisement has been selected by theAdRotator control.
How to bind XML file in AdRotator
Click new Data Source
Select XML file and click ok.
Browse and select XML file and click ok.
Run The Project
When Page will refresh the next image will be displayed
When you click on the image then it will be redirected to the specified page.
Leave Comment